package cn.cnsy123.shorturls.api.controller.business;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.cnsy123.shorturls.api.controller.param.LoginRequestParam;
import cn.cnsy123.shorturls.api.controller.vo.SysLoginResult;
import cn.cnsy123.shorturls.business.service.SysUserLoginInfoService;

@Controller
public class LoginController {
    
    private static final Logger logger = LoggerFactory.getLogger(LoginController.class);
    
    @Autowired(required = true)
    @Qualifier(value = "sysUserLoginInfoService")
    private SysUserLoginInfoService sysUserLoginInfoService;

    @RequestMapping(value = "/login",method = RequestMethod.POST)
    @ResponseBody
    public SysLoginResult login(LoginRequestParam loginRequestParam,HttpServletRequest request,HttpServletResponse response) {
        try {
            return sysUserLoginInfoService.loginProcess(loginRequestParam,request,response);
        } catch (Exception e) {
            logger.error("登录接口-请求异常",e);
            return new SysLoginResult(500, "登录请求异常！");
        }
    }
    
    
    
}
